package com.cn.hnust.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cn.hnust.dao.MessageMapper;
import com.cn.hnust.pojo.Message;
import com.cn.hnust.service.IMessageService;
import com.cn.hnust.util.Page;
@Service("messageservice")
public class MessageServiceImpl implements IMessageService {

	@Autowired
	private MessageMapper messageDao;
	
	
	public Message getUserById(Integer userId) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	
	public List<Message> getUsers() {
		// TODO Auto-generated method stub
		
		return messageDao.getUsers();
	}

	
	public Message getUser(String message_name) {
		// TODO Auto-generated method stub
		
		return messageDao.getUser(message_name);
	}

	
	public int insert(Message user) {
		// TODO Auto-generated method stub
		
		if(user!=null){
			return messageDao.insert(user);
		}else{
		
		return 0;
	}
	}

	
	public int delmessage(Integer id) {
		// TODO Auto-generated method stub
		int a=messageDao.deleteByPrimaryKey(id);
		if(a<0){
		return 0;
		
	}else{
		return messageDao.deleteByPrimaryKey(id);
	}

}

	
	public List<Message> selectPersons(String message_name,Page page) {
		// TODO Auto-generated method stub
		List<Message> message=messageDao.selectPersons(message_name,page);
		if(message!=null){
			return messageDao.selectPersons(message_name,page);
		}else{
			return null;
		}
		
	}

	
	public List<Message> queryAllRecord(Page page) {
		// TODO Auto-generated method stub
		
		
		return messageDao.queryAllRecord(page);
	}

	
	public int getCount() {
		// TODO Auto-generated method stub
		
		return messageDao.getCount();
	}

	
	public int updateByPrimaryKey(Message message) {
		// TODO Auto-generated method stub
		int a = messageDao.updateByPrimaryKey(message);
		if(a < 0){
			
			return messageDao.updateByPrimaryKey(message);
		}
		return 0;
	}

	
	public int getCountmh(String message_name) {
		// TODO Auto-generated method stub
		messageDao.getCountmh(message_name);
		return messageDao.getCountmh(message_name);
	}
	
	
	public int getCounts(String message_name){
		return messageDao.getCounts(message_name);
		
		
	}
}